package com.copa.l1502;

import java.util.Arrays;

/**
 * @author copa
 * @createDate 2022-08-29 15:52
 * @function 排序+遍历法
 */
public class Test1 {

    public boolean canMakeArithmeticProgression(int[] arr) {
        if (arr.length == 2) {
            // 这个是leetcode自己定义是可以的...理论上来说应该不可以才对...
            return true;
        }
        Arrays.sort(arr);
        int diff = arr[1] - arr[0];
        for (int i = 0; i < arr.length - 1; i++) {
            if (arr[i + 1] - arr[i] != diff) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        int[] arr = {3,5,1};
        System.out.println(new Test1().canMakeArithmeticProgression(arr));
    }
}
